	
	function reverse(){
		var cbList = document.getElementsByTagName('input');
		for(var i=0; i<cbList.length; i++){
			cbList[i].checked = !cbList[i].checked;
		}
	}
	
	function selectAll(cbAll){
		var checked = cbAll.checked;
		var cbList = document.getElementsByTagName('input');
		for(var i=0; i<cbList.length; i++){
			if(cbList[i]!=cbAll){
				cbList[i].checked = checked;
			}
		}
	}
	
	function show(v){
		var cbList = document.getElementsByTagName('input');
		for(var i=0; i<cbList.length; i++){
			var cb = cbList[i];
			if(!cb.checked){
				continue;
			}
			var href = cb.parentNode.getAttribute('href');
			if(!href){
				continue;
			}
			var pos = href.indexOf('#');
			if(pos==-1){
				continue;
			}
			
			var id = href.substr(1);
			
			var sd = v?'':'none';
			var color = v?'':'#999';
			
			var e = document.getElementById(id);
			if(e){
				e.style.display = sd;
			}
			var te = document.getElementById(id+"_table");
			if(te){
				te.style.display = sd;
			}
			cb.parentNode.style.color = color;
		}
	}
	
	function getCheckBoxes(){
		var menuForm = document.getElementById('menuForm');
		var es = menuForm.elements;
		return es;
	}

	function addMenuItem(anchorId, parentId){
		if(!parentId){
			parentId = 'suspendedMenu';
		}else{
			parentId = 'MENU_ITEM_'+parentId;
		}
		var nodeId = 'MENU_ITEM_'+anchorId;
		var href = '#'+anchorId;
		var e = document.getElementById(anchorId);
		if(!e)return;
		var text = e.innerHTML||e.innerContent;
		var parent = document.getElementById(parentId);
		var menuItem = document.createElement('div');
		menuItem.id = nodeId;
		menuItem.className = 'menuItem_'+e.tagName;
		var linkNode = document.createElement("a");
		linkNode.href = href;
		linkNode.innerHTML = '<input type="checkbox" />' + text;
		menuItem.appendChild(linkNode);
		parent.appendChild(menuItem);
	}

	function scrollMenu() {
		var menu = document.getElementById("suspendedMenu");
		var pos = document.body.scrollTop||document.documentElement.scrollTop;
		menu.style.top = pos+'px';
	}

	function switchMenu(evt){
		var event = window.event || evt || arguments.callee.caller.arguments[0];
		var srcElement = event.target||event.srcElement;
		if(event.ctrlKey){

		}
		if(srcElement.nodeName!='BODY'){
			return;
		}
		var menu = document.getElementById("suspendedMenu");
		if(menu.style.display!='block'){
			menu.style.display = 'block';
		}else{
			menu.style.display = 'none';
		}
		return false;
	};
	
	function createMenu(){
		var menuDiv = document.createElement('div');
		menuDiv.id = 'suspendedMenu';
		document.documentElement.appendChild(menuDiv);
	}

	window.onload=function(){
		window.onscroll = scrollMenu;
		window.onresize = scrollMenu;
		document.body.ondblclick = switchMenu;
	}

	
	